<template>
  <div ref="fileLine" class="line-chart"></div>
  <div ref="filePie" class="pie-chart"></div>
</template>
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
import { getData } from '@/api/sys/dev/reportDataSetManager';
import { useECharts } from '@/hooks/web/useECharts';
const fileLine = ref();
const filePie = ref();

onMounted(async () => {
  const { setOptions: setLineOptions } = useECharts(fileLine.value);
  const { setOptions: setPieOptions } = useECharts(filePie.value);
  const lineData = await getData({ setCode: 'file_info_line' });
  const pieData = await getData({ setCode: 'file_info_pie' });
//   const data = lineData.
  setLineOptions({
    title: {
      text: 'Stacked Line',
    },
    tooltip: {
      trigger: 'axis',
    },
    legend: {
      data: lineData.legend,
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true,
    },
    toolbox: {
      feature: {
        saveAsImage: {},
      },
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: lineData.xData,
    },
    yAxis: {
      type: 'value',
    },
    series: [
      {
        name: 'Email',
        type: 'line',
        stack: 'Total',
        data: [120, 132, 101, 134, 90, 230, 210],
      },
      {
        name: 'Union Ads',
        type: 'line',
        stack: 'Total',
        data: [220, 182, 191, 234, 290, 330, 310],
      },
      {
        name: 'Video Ads',
        type: 'line',
        stack: 'Total',
        data: [150, 232, 201, 154, 190, 330, 410],
      },
      {
        name: 'Direct',
        type: 'line',
        stack: 'Total',
        data: [320, 332, 301, 334, 390, 330, 320],
      },
      {
        name: 'Search Engine',
        type: 'line',
        stack: 'Total',
        data: [820, 932, 901, 934, 1290, 1330, 1320],
      },
    ],
  });
});
</script>
<style lang="less" scoped>
.line-chart {
  height: 300px;
}
.pie-chart {
  height: 400px;
}
</style>
